# Maintainer: Miles Alan <m@milesalan.com>
pkgname=mepo
pkgver=1.2.1
pkgrel=0
_pkgdescbase="Fast, simple, and hackable OSM map viewer for Linux"
pkgdesc="$_pkgdescbase (base SDL application)"
url="https://git.sr.ht/~mil/mepo"
arch="aarch64 x86_64" # Limited by zig aport
license="GPL-3.0-or-later"
makedepends="
	curl-dev
	sdl2-dev
	sdl2_gfx-dev
	sdl2_image-dev
	sdl2_ttf-dev
	zig>=0.12.0
	"
source="
	$pkgname-$pkgver.tar.gz::https://git.sr.ht/~mil/mepo/archive/$pkgver.tar.gz
	"
subpackages="
	$pkgname-doc
	$pkgname-scripts:scripts:noarch
"

# We may want other than "baseline" for other targets, when enabled by zig
case "$CARCH" in
	aarch64|x86_64) cputarget=baseline ;;
esac

build() {
	zig build -Doptimize=ReleaseSafe ${cputarget:+-Dcpu="$cputarget"}
	zig-out/bin/mepo -docman > mepo.1
}

check() {
	zig build test
}

package() {
	install -Dm755 zig-out/bin/mepo* -t "$pkgdir/usr/bin/"
	install -Dm644 zig-out/share/applications/mepo.desktop -t "$pkgdir/usr/share/applications/"
	install -Dm644 zig-out/share/pixmaps/mepo.png -t "$pkgdir/usr/share/pixmaps/"
	install -Dm644 mepo.1 -t "$pkgdir/usr/share/man/man1/"
}

scripts() {
	pkgdesc="$_pkgdescbase (including base SDL application & scripts)"
	depends="$pkgname=$pkgver-r$pkgrel zenity curl findutils xwininfo geoclue jq ncurses font-hack-nerd"
	mkdir -p "$subpkgdir"
	amove usr/bin/mepo_*
}

sha512sums="
1db1218a1cc43e4c4838f2b96c47ed3c0589efef2bff3aa7175a658e227b339032c22c0af3a4c95eb6b95a759d62315fd2a3fdf5e11706847c7fa02db5c7d63e  mepo-1.2.1.tar.gz
"
